JS.Class('Cool.Fx.FadeSlide', function (ui, dir){
	var box = $(ui),
		index = 0,
		hover,
		scroller = box.find('div.slide_box'),
		navbox = box.find('.slide_nav'),
		nav = navbox.find('a'),
		items = box.find('div.slide_box a');
	
	scroller.css('position', 'relative');
	if (dir === 'y') {
		navbox.css('top', (box.height() - navbox.height())/2.5);
	}	
	items.each(function (i){
		$(this).css({
			position: 'absolute',
			left: 0,
			top: 0,
			zIndex: items.length - i
		});
	});
	box.hover(function (){
		hover = true;
	}, function (){
		hover = false;
	});
	nav.each(function (i){
		this.slide_index = i;
	}).mouseover(function (){
		document.title = this.slide_index;
		show(this.slide_index, index);
	});
	function show(i, old){
		i = JS.range(i, 0, items.length - 1, true);
		if (i === old) {
			return;
		}
		items.css('zIndex', 1);
		items.eq(old).css('zIndex', 5);
		items.eq(i).css({
			'opacity': 0,
			'zIndex': 10
		});
		items.eq(i).stop().fadeTo(400, 1);
		nav.removeClass('current');
		nav.eq(i).addClass('current');
		index = i;
	}
	this.next = function (){
		if (!hover) {
			show(index+1, index);
		}		
	}
	setInterval(this.bind('next'), 3500);
});

JS.ready(function (){
	$('ul.ll img').hover(function (){
		$(this).fadeTo(200, 0.8);
	}, function (){
		$(this).fadeTo(200, 1);
	});
	$('a.bt-more').hover(function (){
		$(this).animate({right: -4},100);
	}, function (){
		$(this).animate({right: 0}, 100);
	});
});

JS.ready(function (){
	$('div.go-top img').click(function (){
		$('html, body').animate({scrollTop: 0});
	});

	$(window).on('resize scroll', function (){
		var tag = $('div.go-top img'),
			stop = $('html').scrollTop() || $('body').scrollTop();
		if (stop > 10) {
			tag.fadeIn();
		}else{
			tag.fadeOut();
		}
	});	
});